<div class="modal fade bs-modal-lg" id="modelContent">
	<div class="modal-dialog modal-lg">
        <div class="modal-content"></div>
    </div>
</div> 
<div class="portlet box green">
    <div class="portlet-title">
		<div class="caption"><i class="fa fa-cogs"></i>数据列表</div>
		<div class="tools"><a href="javascript:;" class="collapse" data-original-title="" title=""> </a></div>
		<div class="actions">
			<a href="javascript:;" class="btn white btn-sm ajax-search"><i class="fa fa-search"></i> 查询 </a>
			<a href="javascript:;" class="btn white btn-sm search-reset"><i class="fa fa-eraser"></i> 清除 </a>
		</div>
    </div>
    <div class="portlet-body">
    	<div class="tabbable-line ">
			<ul class="nav nav-tabs ">
				<li ><a href="weChatMessage/sendBox" class="ajaxify">微信模板</a></li>
				<li><a href="weChatMessage/custom" class="ajaxify">自定义消息</a></li>
				<li  class="active"  ><a href="weChatMessage/sendBox"  class="ajaxify">发件箱</a></li>
				<li><a href="weChatMessage/config"  class="ajaxify">微信配置</a></li>
			</ul>
			<div class="portlet-body form">
				<form action="/weChatMessage/list"  class="form-horizontal" method="get" id="searchForm" onsubmit="return false" >
					<div class="form-body">
						<div class="row">
							<div class="form-group">
								<div class="col-md-3">
									<label class="col-md-4 control-label">模板ID:</label>
									<div class="col-md-8">
										<input type="text" class="form-control" name="id" value="$!templateId">
									</div>
								</div>
								<div class="col-md-3">
									<label class="col-md-4 control-label">发送状态:</label>
									<div class="col-md-8">
										<select class="form-control">
											<option value="">请选择</option>
											<option #if($!sendStatus == 'true') selected="selected"  #end value="true">已发送</option>
											<option #if($!sendStatus == 'false') selected="selected" #end value="false">发送失败</option>
										</select>
									</div>
								</div>
								<div class="col-md-3">
									<label class="control-label col-md-4">发送时间</label> <label
										class="col-md-8"> <input class="form-control"
										type="text" name="startTime" id="startTime"
										value="$!startTime" readonly> <i
										class="fa fa-calendar"
										style="position: absolute; right: 10px; top: 10px"></i>
									</label>
								</div>
								<div class="col-md-3">
									<label class="control-label col-md-2">至：</label> <label
										class="col-md-8"> <input class="form-control"
										type="text" name="endTime" id="endTime" value="$!endTime"
										readonly> <i class="fa fa-calendar"
										style="position: absolute; right: 10px; top: 10px"></i>
									</label>
								</div>
							</div>
							<div class="form-group">
								<div class="col-md-3">
									<label class="control-label col-md-4">消息类型：</label> <label
										class="col-md-8"> <select class="form-control">
											<option>请选择</option>
											<option #if($!msgType == "模板消息") selected="selected" #end  >模板消息</option>
											<option #if($!msgType == "自定义消息")  selected="selected"  #end  >自定义消息</option>
									</select>
									</label>
								</div>
							</div>
						</div>
					</div>
				</form>
			</div>
			<div>
				<a href="javascript:;"   class="btn white btn-sm delete-tab" ><i class="fa fa-trash"></i>批量删除</a>
			</div>
			<div class="tab-content">
				<div class="portlet-body form">
                    <div class="form-body">
 						<div class="table-scrollable">
						   <table class="table table-striped table-bordered table-hover" id="tableCategory">
							  	<thead>
									<tr>
										<th style="width: 20px">
											<input type="checkbox" class="icheck group-icheck"/>
										</th>
										<th>会员号</th>
										<th>消息内容</th>
										<th>模板ID</th>
										<th>发送状态</th>
										<th>消息类型</th>
										<th>发送时间</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody>
									#foreach($item in $!items.result)
										<tr>
											#set($userInfo = $!userInfoMap.get($!item))
											<td>
												<input type="checkbox" name="checkboxes" class="icheck" value="$!item.id" />
											</td>
											<td>$!userInfo.id</td>
											<td>$!item.content</td>
											<td>$!item.templateId</td>
											<td>$!item.sendStatus</td>
											<td>$!item.msgType</td>
											<td>$!item.sendTime</td>
											<td><a href="#modelContent" class="btn green btn-outline btn-sm ajax-model-get"  data-toggle="modal"  thref="/weChatMessage/detail?id=$!item.id"><i class="fa fa-edit" ></i>编辑</a></td>
										</tr>
									#end
								</tbody>
							</table>
						</div>
						#set($page= $!items)
						#set($pageUrl="/weChatMessage/sendBox?$!queryString&pageNo=")
						#parse("_page.htm")
                    </div>
				</div>
			</div>
		</div>
    </div>
</div>
<script type="text/javascript" src="/assets/scripts/views-icheck.js"></script>
<script type="text/javascript">
function getcbvalue(){
		var array = new Array()
		var target= $("input[name='checkboxes']");
		//循环加入数组
		
			$.each(target,function(i,v){
				if(v.checked){
					array.push($(v).val());
				}
			});
	 	return array; 
  }
/**
 * 批量下架
 */
$(".delete-tab").click(function(){
	var idArray= getcbvalue();
	if(idArray.length>0){
		bootbox.setLocale("zh_CN");
		bootbox.confirm("确定删除吗？", function(state) {
			if(state){
			   	 $.post("weChatMessage/deleteMessageLog",{"idArray":idArray},function(result){
			        	
			   		 	if(result.code==0){
			        		toastr.success(result.msg);
			        		pageContentBody.load("weChatMessage/weChatSendBox");
			   		 	}else {
			       			toastr.warning(result.msg);
			       		}
				   },"json");
			}
		});
		}else{
			toastr.warning("请勾选需要下架的商品！");
		}
});

$('.group-icheck').on('ifChecked', function(){
	$("input[type='checkbox']").iCheck('check');
})

$('.group-icheck').on('ifUnchecked', function(){
	$("input[type='checkbox']").iCheck('uncheck');
})
</script>